#include "stdafx.h"
#include "Common.h"

DWORD Color2RGBA(DATA_TYPE r, DATA_TYPE g, DATA_TYPE b, DATA_TYPE a)
{
	return ((DWORD)(a * 255.f) << 24) 
		 | ((DWORD)(b * 255.f) << 16) 
		 | ((DWORD)(g * 255.f) << 8) 
		 | ((DWORD)(r * 255.f));
}

DATA_TYPE Round(DATA_TYPE x)
{
	DATA_TYPE t;
	if (x >= 0.f)
	{
		t = ceilf(x);
		if (t - x > 0.5f)
			t -= 1.0f;
		return t;
	}
	else
	{
		t = ceilf(-x);
		if (t + x > 0.5f)
		{
			t += 1.0f;
		}
		return -t;
	}
}
